﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZHDJ.Data.Models.Forum
{
    /// <summary>
    /// 版主设置
    /// </summary>
    public class PartyForumTypeAdmin : EntityBase
    {
        #region 属性

        /// <summary>
        /// 版块ID
        /// </summary>
        public string TypeID { get; set; }

        /// <summary>
        /// 用户ID
        /// </summary>
        public string LoginID { get; set; }
        #endregion

        #region 查询管理
        public static DataTable GetTitleLoginID(string typeid)
        {
            StringBuilder sbSql = new StringBuilder();
            List<MySqlParameter> parameters = new List<MySqlParameter>();

            sbSql.Append(@"select a.LoginID,b.UserName from tblPartyForumTypeAdmin a 
left join tblpartyorgmember b on a.LoginID=b.LoginID where a.TypeID=?typeid");
            parameters.Add(new MySqlParameter() { DbType = DbType.String, ParameterName = "typeid", Value = typeid });

            return MySqlHelper.ExecuteDataTable(sbSql.ToString(), parameters.ToArray());
        }

        public static bool IsForumTypeAdmin(string typeID, string loginID)
        {
            using (var DB = new DBInstance().DB)
            { 
                return DB.PartyForumTypeAdmins.Count(a => a.TypeID == typeID && a.LoginID == loginID) > 0;
            }
           
        }
        #endregion
    }
}
